<template>
  <view class="product-item" @click="$utils.jumpPage(`/pages_index/work_detail?id=${productData.id||''}`)">
    <image class="img" :src="$utils.formatAttachmentUrl(productData.image_url)" mode="widthFix"></image>
    <view class="info">
      <view class="name">{{ productData.title || '' }}</view>
      <view class="basic-flex-sb other">
        <view class="basic-flex left">
          <image class="avatar" :src="$utils.formatAttachmentUrl(productData.avatar)"></image>
          <view class="main">
            <view class="row_1">{{ productData.nickname || '' }}</view>
            <view class="row_2">{{ $utils.formatDate(productData.createtime, 'yyyy/MM/dd') }}</view>
          </view>
        </view>
        <view class="right">￥{{ productData.price || '' }}</view>
      </view>
      <view class="basic-flex-horizontal tag">
        <image v-if="info.is_praise===0" class="icon" src="/static/base/icon_2zan.png"></image>
        <image v-if="info.is_praise===1" class="icon" src="/static/base/icon_2zan1.png"></image>
        <view class="num">{{ productData.praise || 0 }}</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'productItem',
  props: {
    productData: {
      type: Object,
      default: {},
    },
  },
};
</script>

<style lang="scss" scoped>
.product-item {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.02);

  & > .img {
    width: 100%;
  }

  & > .info {
    position: relative;
    padding: 6px 6px 10px;

    & > .name {
      font-weight: bold;
      font-size: 14px;
      color: #000000;
      margin-bottom: 10px;
    }

    & > .other {
      gap: 5px;
      align-items: flex-start;

      & > .left {
        gap: 4px;

        & > .avatar {
          width: 20px;
          height: 20px;
          border-radius: 50%;
        }

        & > .main {
          font-weight: 400;
          color: #666666;

          & > .row_1 {
            font-size: 13px;
            margin-bottom: 2px;
          }

          & > .row_2 {
            font-size: 11px;
          }
        }
      }

      & > .right {
        font-weight: 500;
        font-size: 14px;
        color: #FE1C41;
      }
    }

    & > .tag {
      position: absolute;
      top: -38px;
      right: 8px;
      padding: 5px 10px;
      gap: 5px;
      background: rgba(0, 0, 0, 0.3);
      border-radius: 12px;

      & > .icon {
        width: 12px;
        height: 12px;
      }

      & > .num {
        font-weight: 400;
        font-size: 11px;
        color: #FFFFFF;
      }
    }

  }
}
</style>
